package com.example.myweb.Repository.JpaRepository;

import com.example.myweb.Domain.Entity.Like;
import com.example.myweb.Domain.Entity.User;
import com.example.myweb.Domain.Enum.LikeTargetType;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.Optional;

public interface LikeRepository extends JpaRepository<Like, Long> {
    // 根据用户、目标类型和目标ID查找点赞记录
    Optional<Like> findByUserAndTargetTypeAndTargetId(User user, Like.LikeTargetType targetType, Long targetId);

    // 用于检查是否已点赞
    boolean existsByUserAndTargetTypeAndTargetId(User user, Like.LikeTargetType targetType, Long targetId);
    long deleteByUserAndTargetTypeAndTargetId(User user, Like.LikeTargetType targetType, Long targetId);

    // === 确保这个方法的签名是使用枚举类型 ===
    List<Like> findAllByUserAndTargetTypeAndTargetIdIn(User user, Like.LikeTargetType targetType, List<Long> targetIds);

}